#include<bits/stdc++.h>
using namespace std;
int b[100010];
int n,a[100010];
int ans=0,k=0,w=0;
int main()
{
	freopen("duel.in","r",stdin);
	freopen("duel.out","w",stdout);
	
	cin>>n;
	for(int i=1;i<=100001;i++)
	{
		b[i]=0;
	}
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[a[i]]++;
	}
	
	for(int i=1;i<=100001;i++)
	{
		if(b[i]!=0)
		{
			ans++;
			if(k==0)
			{
				k=b[i];
			}
			if(w==0)
			{
				w=b[i];
			}

		}
	}
	if(ans==2)
		cout<<min(k,w);
	else if(ans==1)
		cout<<k/2;
	else
		cout<<n-(n%3)-1;
	
	
/*	sort(a+1,a+1+n);
	int min=a[1];
	for(int i=2;i<=n;i++)
	{
		if(a[i]==min)
			ans+=1;
	}
	
	while(ans!=0)
	{
		for(int i=ans+1;i<=n;i++)
		{
			b[i]=1;
			a[i-ans]=0;
			ans--;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]!=0)
			ans++;
	}
	cout<<ans;
	* */
	return 0;
}
